#include <iostream>
using namespace std;
char plate[9] = {"MDA00000"};
int dates[5] = {1, 1, 1, 1, 1};
int main()
{
    char ch;
    bool flag = true;
    for (int i = 0; i < 8; ++i)
    {
        cin >> ch;
        if (i < 3) //区域码
        {
            if (plate[i] != ch)
            {
                flag = false;
                break;
            }
        }
        plate[i] = ch;
    }
    if (flag)
        fill(dates, dates + 5, 0);
    for (int i = 7; i >= 0 && flag; --i)
    {
        ch = plate[i];
        if (isdigit(ch))
        {
            ch -= '0';
            if (ch > 5)
                ch = 10 - ch;
            if (ch == 0)
                ch = 5;
            dates[ch - 1] = 1;
            break;
        }
    }
    for (int i = 0; i < 5; ++i)
        cout << dates[i] << " ";
    return 0;
}